package XmlLoader;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
/* class FGObjectStructure : store each point information of trajectory of one object */
public class FGObjectStructure 
{
	protected int pointid = 0;
	protected Position centerReal = new Position();
	protected Position centerPredict = new Position();
	protected Position posReal = new Position();
	protected Position posPredict = new Position();
	protected Position posReal_Forward = new Position();
	protected Position posReal_Backward = new Position();
	protected int width = 0, height = 0;
	protected int tSynopsis = 0;
	protected int tOrigin = 0;
	/* Function ACT001 : store all data of node to this object */
	public void ACT001_storeInfo(Node node)
	{
		int curReadIndex = 0;
    	String curTitle = null;
    	Node curNode = null, curNodeFirstItem = null;
    	NodeList nodeList = node.getChildNodes();
    	while(curReadIndex < nodeList.getLength())
    	{
    		curNode = nodeList.item(curReadIndex);
    		curTitle = curNode.getNodeName();
    		curNodeFirstItem = curNode.getChildNodes().item(0);
    		if(curTitle.compareTo("pointid") == 0)
    		{
    			this.pointid = Integer.parseInt(curNodeFirstItem.getNodeValue());
    		}
    		else if(curTitle.compareTo("centerReal_x") == 0)
    		{
    			this.centerReal.x = Integer.parseInt(curNodeFirstItem.getNodeValue());
    		}
    		else if(curTitle.compareTo("centerReal_y") == 0)
    		{
    			this.centerReal.y = Integer.parseInt(curNodeFirstItem.getNodeValue());
    		}
    		else if(curTitle.compareTo("centerPredict_x") == 0)
    		{
    			this.centerPredict.x = Integer.parseInt(curNodeFirstItem.getNodeValue());
    		}
    		else if(curTitle.compareTo("centerPredict_y") == 0)
    		{
    			this.centerPredict.y = Integer.parseInt(curNodeFirstItem.getNodeValue());
    		}
    		else if(curTitle.compareTo("posReal_x") == 0)
    		{
    			this.posReal.x = Integer.parseInt(curNodeFirstItem.getNodeValue());
    		}
    		else if(curTitle.compareTo("posReal_y") == 0)
    		{
    			this.posReal.y = Integer.parseInt(curNodeFirstItem.getNodeValue());
    		}
    		else if(curTitle.compareTo("posPredict_x") == 0)
    		{
    			this.posPredict.x = Integer.parseInt(curNodeFirstItem.getNodeValue());
    		}
    		else if(curTitle.compareTo("posPredict_y") == 0)
    		{
    			this.posPredict.y = Integer.parseInt(curNodeFirstItem.getNodeValue());
    		}
    		else if(curTitle.compareTo("posReal_Forward_x") == 0)
    		{
    			this.posReal_Forward.x = Integer.parseInt(curNodeFirstItem.getNodeValue());
    		}
    		else if(curTitle.compareTo("posReal_Forward_y") == 0)
    		{
    			this.posReal_Forward.y = Integer.parseInt(curNodeFirstItem.getNodeValue());
    		}
    		else if(curTitle.compareTo("posReal_Backward_x") == 0)
    		{
    			this.posReal_Backward.x = Integer.parseInt(curNodeFirstItem.getNodeValue());
    		}
    		else if(curTitle.compareTo("posReal_Backward_y") == 0)
    		{
    			this.posReal_Backward.y = Integer.parseInt(curNodeFirstItem.getNodeValue());
    		}
    		else if(curTitle.compareTo("tSynopsis") == 0)
    		{
    			this.tSynopsis = Integer.parseInt(curNodeFirstItem.getNodeValue());
    		}
    		else if(curTitle.compareTo("tOrigin") == 0)
    		{
    			this.tOrigin = Integer.parseInt(curNodeFirstItem.getNodeValue());
    		}
    		curReadIndex = curReadIndex + 1;
    	}
	}
	/* Function ACT002 : show all attribute value of this object for testing */
	public void ACT002_showInfo()
	{
		System.out.println("      pointid = " + this.pointid);
		System.out.println("      centerReal_x = " + this.centerReal.x);
		System.out.println("      centerReal_y = " + this.centerReal.y);
		System.out.println("      centerPredict_x = " + this.centerPredict.x);
		System.out.println("      centerPredict_y = " + this.centerPredict.y);
		System.out.println("      posReal_x = " + this.posReal.x);
		System.out.println("      posReal_y = " + this.posReal.y);
		System.out.println("      posPredict_x = " + this.posPredict.x);
		System.out.println("      posPredict_y = " + this.posPredict.y);
		System.out.println("      posReal_Forward_x = " + this.posReal_Forward.x);
		System.out.println("      posReal_Forward_y = " + this.posReal_Forward.y);
		System.out.println("      posReal_Backward_x = " + this.posReal_Backward.x);
		System.out.println("      posReal_Backward_y = " + this.posReal_Backward.y);
		System.out.println("      tSynopsis = " + this.tSynopsis);
		System.out.println("      tOrigin = " + this.tOrigin);
	}
	/* Function ACT003 : catching position information of this object */
	public String ACT003_getFileString()
	{
		String str = "";
		str = str + this.centerReal.x + " " + this.centerReal.y;
		return str;
	}
	public Position GET001_centerReal()
	{
		return new Position(this.posReal.x + (int)(0.5*this.width), this.posReal.y + this.height);
	}
	public int GET002_tOrigin()
	{
		return this.tOrigin;
	}
	public int GET003_pointid()
	{
		return this.pointid;
	}
	public int GET004_tOrigin()
	{
		return this.tOrigin;
	}
	public int[] GET005_boxSize() {
		int[] v = {this.width, this.height};
		return v;
	}
	public Size GET006_boxSize() {
		return new Size(this.centerReal, this.width, this.height);
	}
	public void SET001_Pointid(int pointid) {
		this.pointid = pointid;
	}
	public void SET002_CenterReal(Position centerReal) {
		this.centerReal = centerReal;
	}
	public void SET003_CenterPredict(Position centerPredict) {
		this.centerPredict = centerPredict;
	}
	public void SET004_PosReal(Position posReal) {
		this.posReal = posReal;
	}
	public void SET005_PosPredict(Position posPredict) {
		this.posPredict = posPredict;
	}
	public void SET006_PosReal_Forward(Position posReal_Forward) {
		this.posReal_Forward = posReal_Forward;
	}
	public void SET007_PosReal_Backward(Position posReal_Backward) {
		this.posReal_Backward = posReal_Backward;
	}
	public void SET008_Width(int width) {
		this.width = width;
	}
	public void SET009_Height(int height) {
		this.height = height;
	}
	public void SET010_tSynopsis(int tSynopsis) {
		this.tSynopsis = tSynopsis;
	}
	public void SET011_tOrigin(int tOrigin) {
		this.tOrigin = tOrigin;
	}
}

